package com.goatrock.media.thisway.domain.utils;

import java.util.List;

public class MMMUtils {

    public static String formatSize(long bytes){
        String size = "";

        if (bytes > 1000000000) {
           size = Math.round(((float)bytes / (float)Math.pow(1024, 3))*100.0)/100.0 + " GB";
        } else if (bytes > 1000000) { 
           size = Math.round(((float)bytes / (float)Math.pow(1024, 2))*100.0)/100.0 + " MB";
        } else if (bytes > 1000) {
           size = Math.round(((float)bytes / (float)1024)*100.0)/100.0 + " KB";
        } else {
           size  = Float.toString (bytes) + " bytes";
        }
        return size;
    }

    public static String[] convertListToString(List list){
        String[] strList = new String[list.size()];
        list.toArray(strList);
        return strList;
    }

    public static String getString(String item){
        if (item != null) {
            return item;
        }else {
            return "";
        }
    }

    public static String formatRunningTime(int runtime){
        if (runtime < 60) {
            return runtime + " minutes";
        }
        int hours = runtime / 60;
        int minutes = runtime % 60;
        return hours + ":" + minutes;

    }
}
